<!doctype html>
<html lang="en">
<head>
    <title>Code coverage report for components\uploader\ajax-upload.vue</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="../../prettify.css" />
    <link rel="stylesheet" href="../../base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type='text/css'>
        .coverage-summary .sorter {
            background-image: url(../../sort-arrow-sprite.png);
        }
    </style>
</head>
<body>
<div class='wrapper'>
  <div class='pad1'>
    <h1>
      <a href="../../index.html">all files</a> / <a href="index.html">components/uploader/</a> ajax-upload.vue
    </h1>
    <div class='clearfix'>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Statements</span>
        <span class='fraction'>0/72</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Branches</span>
        <span class='fraction'>0/40</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Functions</span>
        <span class='fraction'>0/8</span>
      </div>
      <div class='fl pad1y space-right2'>
        <span class="strong">0% </span>
        <span class="quiet">Lines</span>
        <span class='fraction'>0/67</span>
      </div>
    </div>
  </div>
  <div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">&lt;template&gt;
	&lt;div class="dx-upload-ajax"&gt;
		&lt;div 
			tabindex="0"
			class="dx-upload-ajax--btn"
			@click.stop="handleClick"
		&gt;
			&lt;dx-button type="primary"&gt;
				点击上传
			&lt;/dx-button&gt;
			&lt;!-- 采用ajax+new formData方式 --&gt;
			&lt;input 
				:name="name"
				:multiple="multiple"
				class="dx-upload-ajax--input" 
				type="file" 
				ref="input" 
				@change.self.stop="handleChange"
			/&gt;
		&lt;/div&gt;
		&lt;div 
			v-if="tip" 
			class="dx-upload-ajax--tip"
		&gt;
			{{tip}}
		&lt;/div&gt;
		&lt;ul class="dx-upload-ajax__file-list" v-if="showFileList"&gt;
			&lt;li v-for="file in fileList"&gt;
				&lt;dx-progress
					v-show="file.state !== 1"
					:percentage="file.percentage"
				&gt;&lt;/dx-progress&gt;
				&lt;div class="dx-upload-ajax__file-list-desc"&gt;
					&lt;span class="dx-upload-ajax__file-list-desc--detail"&gt;
						&lt;span&gt;{{file.name}}&lt;/span&gt;
						&lt;span&gt;{{file.size | fileSizeToUnit}}&lt;/span&gt;
					&lt;/span&gt;
					&lt;span 
						@click="removeFile(file.fileId)"
						class="dx-upload-ajax__file-list-desc--close"&gt; 
						删除 
					&lt;/span&gt;
				&lt;/div&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
&lt;/template&gt;
&lt;script&gt;
	import {
	  uploadHelper,
	  imageFileExtension,
	  docFileExtension,
	  IGuid,
	  getFileType,
	  fileSizeToUnit,
	  isExceedSizeLimit,
	  SIZE_UNIT
	} from './upload-helper'
	import DxProgress from '@/components/progress/dx-progress.vue'
	export default {
		props: {
			name: {
				type: String,
				default: 'file'
			},
			action: {
				type: String,
				required: true
			},
			multiple: {
				type: Boolean,
				default: true
			},
			accept: Array,
			limit: {
				type: Number,
				default: 8
			},
			httpRequest: {
				type: Function,
				default: uploadHelper
			},
			unit: {
				validator: function(value)<span class="fstat-no" title="function not covered" > {</span>
<span class="cstat-no" title="statement not covered" >					return SIZE_UNIT.includes(value)</span>
				},
				default: 'MB'
			},
			tip: String,
			autoUpload: {
				type: Boolean,
				default: true
			},
			onRemove: Function,
			onBefore: Function,
			onProgress: Function,
			onSuccess: Function,
			onError: Function,
			withCredentials: Boolean,
			showFileList: {
				type: Boolean,
				default: true
			}
		},
		components: {
			DxProgress
		},
		data() {
<span class="cstat-no" title="statement not covered" >			return {</span>
				fileList: []
			}
		},
		computed: {
			allowFileExtension() {
<span class="cstat-no" title="statement not covered" >				return this.accept ? this.accept : [...docFileExtension, ...imageFileExtension]</span>
			},
			fileNum() {
<span class="cstat-no" title="statement not covered" >				return this.fileList.length</span>
			}
		},
		filters: {
			fileSizeToUnit(value) {
<span class="cstat-no" title="statement not covered" >				value = parseFloat(value)</span>
<span class="cstat-no" title="statement not covered" >				if (isNaN(value))<span class="cstat-no" title="statement not covered" > return 0</span></span>
<span class="cstat-no" title="statement not covered" >				return fileSizeToUnit(value)</span>
			}
		},
		methods: {
			handleClick() {
<span class="cstat-no" title="statement not covered" >				if (!this.disabled) {</span>
<span class="cstat-no" title="statement not covered" >					this.$refs.input.value = null</span>
<span class="cstat-no" title="statement not covered" >					this.$refs.input.click()</span>
				}
			},
			handleChange(ev) {
				// 得到所有文件
				let files =<span class="cstat-no" title="statement not covered" > Array.from(ev.target.files)</span>
<span class="cstat-no" title="statement not covered" >				if (files) {</span>
<span class="cstat-no" title="statement not covered" >					this.uploadFiles(files)</span>
				}
			},
			uploadFiles(postFiles) {
				// 如果设置自动发送
<span class="cstat-no" title="statement not covered" >				if (postFiles.length === 0) {<span class="cstat-no" title="statement not covered" > return</span> }</span>
<span class="cstat-no" title="statement not covered" >				postFiles.forEach(rawFile =&gt;<span class="fstat-no" title="function not covered" > {</span></span>
					let fileId =<span class="cstat-no" title="statement not covered" > IGuid()</span>
					let file =<span class="cstat-no" title="statement not covered" > {</span>
						status: 0,
						fileId,
						raw: rawFile,
						name: rawFile.name,
						size: rawFile.size,
						percentage: 0
					}
					// 验证文件格式以及大小等
<span class="cstat-no" title="statement not covered" >					if (!this.validateFileValue(file)) {</span>
<span class="cstat-no" title="statement not covered" >						return</span>
					}
<span class="cstat-no" title="statement not covered" >					if (this.onBefore &amp;&amp; !this.onBefore(file)) {</span>
<span class="cstat-no" title="statement not covered" >						return</span>
					}
<span class="cstat-no" title="statement not covered" >					this.fileList.push(file)</span>
					// 设置为自动上传
<span class="cstat-no" title="statement not covered" >					if (this.autoUpload) {</span>
<span class="cstat-no" title="statement not covered" >						this.doPostFile(file, fileId)</span>
					}
				})
			},
			doPostFile(file, fileId) {
				let options =<span class="cstat-no" title="statement not covered" > {</span>
					withCredentials: this.withCredentials,
					action: this.action,
					filename: this.name,
					file: file.raw,
					onSuccess: (data) =&gt;<span class="fstat-no" title="function not covered" > {</span>
<span class="cstat-no" title="statement not covered" >						this.onUploadSucess(data)</span>
					},
					onProgress: (data) =&gt;<span class="fstat-no" title="function not covered" > {</span>
<span class="cstat-no" title="statement not covered" >						this.onUploadProgress(data, file)</span>
					},
					error: (data) =&gt;<span class="fstat-no" title="function not covered" > {</span>
<span class="cstat-no" title="statement not covered" >						console.error(data)</span>
<span class="cstat-no" title="statement not covered" >						this.onUploadError(data, fileId)</span>
					}
				}
<span class="cstat-no" title="statement not covered" >				file.xhr = this.httpRequest(options)</span>
			},
			onUploadProgress(data, file) {
<span class="cstat-no" title="statement not covered" >				file.percentage = data.percentage</span>
<span class="cstat-no" title="statement not covered" >				this.onProgress &amp;&amp; this.onProgress(data)</span>
			},
			onUploadSucess(data) {
				let file =<span class="cstat-no" title="statement not covered" > this.fileList.find(element =&gt;<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" > element.fileId === data.fileId</span></span>)</span>
<span class="cstat-no" title="statement not covered" >				file.state = 1</span> // 设置为完成状态
<span class="cstat-no" title="statement not covered" >				file.attachmentId = data.attachmentId</span>// 上传真正文件名
<span class="cstat-no" title="statement not covered" >				file.thumbnailUrl = data.thumbnailUrl</span> // 上传图片缩略图，目前图片暂未压缩
<span class="cstat-no" title="statement not covered" >				this.onSuccess &amp;&amp; this.onSuccess(file)</span>
			},
			onUploadError(data, fileId) {
<span class="cstat-no" title="statement not covered" >				this.removeFileFromFileList(fileId)</span>
<span class="cstat-no" title="statement not covered" >				this.onError &amp;&amp; this.onError(data)</span>
<span class="cstat-no" title="statement not covered" >				this.$message.error(`上传文件失败，请重新上传: ${data}`)</span>
			},
			// 移除文件
			async removeFile(fileId) {
				let findIndex =<span class="cstat-no" title="statement not covered" > this.fileList.findIndex(element =&gt;<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" > element.fileId === fileId</span></span>)</span>
<span class="cstat-no" title="statement not covered" >				if (findIndex &lt; 0) {</span>
<span class="cstat-no" title="statement not covered" >					return</span>
				}
				let file =<span class="cstat-no" title="statement not covered" > this.fileList[findIndex]</span>
<span class="cstat-no" title="statement not covered" >				if (file) {</span>
<span class="cstat-no" title="statement not covered" >					if (file.xhr) {</span>
<span class="cstat-no" title="statement not covered" >						file.xhr.abort()</span>
					}
					// 删除添加的文件
<span class="cstat-no" title="statement not covered" >					try {</span>
<span class="cstat-no" title="statement not covered" >						this.onRemove &amp;&amp; await this.onRemove(file)</span>
					} catch (e) {
<span class="cstat-no" title="statement not covered" >						console.error(e)</span>
<span class="cstat-no" title="statement not covered" >						return</span>
					}
				}
<span class="cstat-no" title="statement not covered" >				this.fileList.splice(findIndex, 1)</span>
			},
			removeFileFromFileList(fileId) {
				let findIndex =<span class="cstat-no" title="statement not covered" > this.fileList.findIndex(element =&gt;<span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" > element.fileId === fileId</span></span>)</span>
<span class="cstat-no" title="statement not covered" >				if (findIndex &lt; 0) {</span>
<span class="cstat-no" title="statement not covered" >					return</span>
				}
<span class="cstat-no" title="statement not covered" >				this.fileList.splice(findIndex, 1)</span>
			},
			// 验证上传文件，合格则添加进uploadList数组
			validateFileValue({ fileId, name, size }) {
				let fileType =<span class="cstat-no" title="statement not covered" > getFileType(name)</span>
				// 检查文件格式
<span class="cstat-no" title="statement not covered" >				if (!this.allowFileExtension.includes(fileType)) {</span>
<span class="cstat-no" title="statement not covered" >					this.$message.warning('不支持的文件上传格式！')</span>
<span class="cstat-no" title="statement not covered" >					return false</span>
				}
				// 检查文件大小，目前默认限制为10MB
<span class="cstat-no" title="statement not covered" >				if (size === 0) {</span>
<span class="cstat-no" title="statement not covered" >					this.$message.warning('文件大小不能为0！')</span>
<span class="cstat-no" title="statement not covered" >					return false</span>
				}
<span class="cstat-no" title="statement not covered" >				if (isExceedSizeLimit(size, this.limit, this.unit)) {</span>
<span class="cstat-no" title="statement not covered" >					this.$message.warning(`文件大小超过限制, 限制大小为${this.limit + this.unit}`)</span>
<span class="cstat-no" title="statement not covered" >					return false</span>
				}
<span class="cstat-no" title="statement not covered" >				return true</span>
			}
		}
	}
&lt;/script&gt;
&lt;style lang="scss"&gt;
	@include B(upload-ajax) {
		@include M(btn) {
			display: inline-block;
		}
		@include M(input) {
			display: none;
		}
		@include M(tip) {
			font-size: 1.2rem;
			color: #666;
			padding-top: 1rem;
		}
		
		@include E(file-list) {
			margin-top: 1rem;
		}
&nbsp;
		@include E(file-list-desc) {
			display: flex;
			align-items: center;
			color: #666;
			font-size: 1.3rem;
			padding: 0.5rem 0;
			cursor: pointer;
			@include M(detail) {
				&gt;span {
					margin-right: 0.5rem;
					font-size: 1.2rem;
				}
			}
&nbsp;
			@include M(close) {
				flex-grow: 1;
				text-align: right;
				&amp;:hover {
					color: #8DD0EC;
				}
			}	
		}
	}
	/* 动画效果 */
	.fade-enter-active, .fade-leave-active {
	  transition: opacity .5s;
	}
	.fade-enter, .fade-leave-to {
	  opacity: 0;
	}
&lt;/style&gt;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
  Code coverage
  generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Feb 24 2019 15:08:50 GMT+0800 (中国标准时间)
</div>
</div>
<script src="../../prettify.js"></script>
<script>
window.onload = function () {
        if (typeof prettyPrint === 'function') {
            prettyPrint();
        }
};
</script>
<script src="../../sorter.js"></script>
</body>
</html>
